package com.ruoyi.finance.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;
import com.ruoyi.finance.domain.TCwHailianDealPerDay;
import com.ruoyi.finance.service.ITCwHailianDealPerDayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 海链财务报(批处理对线上收入每天分类汇总统计一条记录，目前只有线上收入)Controller
 * 
 * @author wish
 * @date 2021-06-18
 */
@RestController
@RequestMapping("/day")
public class TCwHailianDealPerDayController extends BaseController
{
    @Autowired
    private ITCwHailianDealPerDayService tCwHailianDealPerDayService;


    @PreAuthorize(hasPermi = "finance:day:findAll")
    @GetMapping("/findAll")
    public AjaxResult findList(){
        System.out.println("我是侯泽浩我真牛逼!!!!!!!!!!!!!!!!!!");
        List<TCwHailianDealPerDay> findAll=tCwHailianDealPerDayService.findAllList();
        System.out.println(findAll+"走着呢走着呢走着呢走着呢！！！！");
        System.out.println("走完了走完了走完了走完了！！！！！！！！");
        return AjaxResult.success("成功",findAll);
    }

    /**
     * 查询海链财务报(批处理对线上收入每天分类汇总统计一条记录，目前只有线上收入)列表
     */
    @PreAuthorize(hasPermi = "finance:day:list")
    @GetMapping("/list")
    public TableDataInfo list(TCwHailianDealPerDay tCwHailianDealPerDay)
    {
        startPage();
        List<TCwHailianDealPerDay> list = tCwHailianDealPerDayService.selectTCwHailianDealPerDayList(tCwHailianDealPerDay);
        return getDataTable(list);
    }

    /**
     * 导出海链财务报(批处理对线上收入每天分类汇总统计一条记录，目前只有线上收入)列表
     */
    @PreAuthorize(hasPermi = "finance:day:export")
    @Log(title = "海链财务报(批处理对线上收入每天分类汇总统计一条记录，目前只有线上收入)", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TCwHailianDealPerDay tCwHailianDealPerDay) throws IOException
    {
        List<TCwHailianDealPerDay> list = tCwHailianDealPerDayService.selectTCwHailianDealPerDayList(tCwHailianDealPerDay);
        ExcelUtil<TCwHailianDealPerDay> util = new ExcelUtil<TCwHailianDealPerDay>(TCwHailianDealPerDay.class);
        util.exportExcel(response, list, "海链财务报(批处理对线上收入每天分类汇总统计一条记录，目前只有线上收入)数据");
    }

    /**
     * 获取海链财务报(批处理对线上收入每天分类汇总统计一条记录，目前只有线上收入)详细信息
     */
    @PreAuthorize(hasPermi = "finance:day:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tCwHailianDealPerDayService.selectTCwHailianDealPerDayById(id));
    }

    /**
     * 新增海链财务报(批处理对线上收入每天分类汇总统计一条记录，目前只有线上收入)
     */
    @PreAuthorize(hasPermi = "finance:day:add")
    @Log(title = "海链财务报(批处理对线上收入每天分类汇总统计一条记录，目前只有线上收入)", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TCwHailianDealPerDay tCwHailianDealPerDay)
    {
        return toAjax(tCwHailianDealPerDayService.insertTCwHailianDealPerDay(tCwHailianDealPerDay));
    }

    /**
     * 修改海链财务报(批处理对线上收入每天分类汇总统计一条记录，目前只有线上收入)
     */
    @PreAuthorize(hasPermi = "finance:day:edit")
    @Log(title = "海链财务报(批处理对线上收入每天分类汇总统计一条记录，目前只有线上收入)", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TCwHailianDealPerDay tCwHailianDealPerDay)
    {
        return toAjax(tCwHailianDealPerDayService.updateTCwHailianDealPerDay(tCwHailianDealPerDay));
    }

    /**
     * 删除海链财务报(批处理对线上收入每天分类汇总统计一条记录，目前只有线上收入)
     */
    @PreAuthorize(hasPermi = "finance:day:remove")
    @Log(title = "海链财务报(批处理对线上收入每天分类汇总统计一条记录，目前只有线上收入)", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tCwHailianDealPerDayService.deleteTCwHailianDealPerDayByIds(ids));
    }
}
